#include<iostream>
#include<bitset>
#include<cstring>
using namespace std;
const int N = 3e4 + 10, M = 1e5 + 10;
int h[N], e[N], ne[N], idx;
int n, m;
int d[N];
int q[M];
bitset<N>f[N];
int cnt, arr[N];
void add(int a, int b)
{
	e[idx] = b, ne[idx] = h[a], h[a] = idx++;
}

void tuopu_sort()
{
	int hh = 0, tt = -1;
	for (int i = 1; i <= n; i++) {
		if (!d[i])q[++tt] = i;
	}
	while (hh <= tt) {
		int t = q[hh++];
		for (int i = h[t]; ~i; i = ne[i]) {
			if (--d[e[i]] == 0) {
				q[++tt] = e[i];
			}
		}
	}
}
int main()
{
	cin >> n >> m;
	memset(h, -1, sizeof(h));
	while (m--) {
		int a, b;
		cin >> a >> b;
		add(a, b);
		d[b]++;
	}
	tuopu_sort();
	for (int i = n - 1; i >= 0; i--) {
		int k = q[i];
		f[k][k] = 1;
		for (int j = h[k]; ~j; j = ne[j]) {
			f[k] |= f[e[j]];
		}
	}
	for (int i = 1; i <= n; i++) {
		cout << f[i].count() << endl;
	}
	return 0;
}